<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // const obj = {};
      // obj.__proto__ = { a: 1 };

      /*
        1. 参数1指定原型
        2. 参数2指定属性和方法
      */
      //  Object.defineProperty({})
      const obj = Object.create(
        { a: 1 },
        {
          age: {
            value: 20,
            writable: true,
            enumerable: true,
            configurable: true,
          },
          add: {
            value: function (a, b) {
              return a + b;
            },
          },
        }
      );
      obj.username = "jack";
      obj.say = function () {};
      console.log(obj);
    </script>
  </body>
</html>
